<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 钉钉链接消息 v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace ding\msg\chat;

/**
 * 链接会话消息
 *
 * @package ding\msg\chat
 */
class LinkChatMsg extends ChatMsg {
    protected $title;
    protected $text;
    protected $messageUrl;
    protected $picUrl;

    /**
     * 链接消息构造函数
     *
     * @param $title
     * @param $text
     * @param $messageUrl
     * @param $picUrl
     */
    public function __construct($title, $text, $messageUrl, $picUrl = "") {
        parent::__construct("link");
        $this->title = $title;
        $this->text = $text;
        $this->messageUrl = $messageUrl;
        $this->picUrl = $picUrl;
    }


    /**
     * 获取消息体
     * {
     *           "text":"这个即将发布的新版本，创始人陈航（花名无招）称它为红树林。而在此之前，每当面临重大升级，产品经理们都会取一个应景的代号，这一次，为什么是红树林”？",
     *           "title": "时代的火车向前开",
     *           "picUrl": "",
     *           "messageUrl": "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI"
     * }
     * @return array
     */
    public function getMsgContent() {
        return [
            'text' => $this->text,
            'title' => $this->title,
            'messageUrl' => $this->messageUrl,
            'picUrl' => $this->picUrl
        ];
    }

}
